Background

Excerpt from the IndyCrash project wiki:

Hi, my name’s Dan, I’m a resident pediatrician in Indianapolis. Several years ago, my good friend Mike was bicycling through the streets of Philadelphia when a car T-boned him after it ran a red light. Mike shattered the tip of his right elbow and his head struck straight into the windshield. He likely would not have survived if he had not been wearing a helmet. He spent months recovering from complex orthopedic surgery with physical rehab.

I love bicycling/walking (aka active mobility). It’s a great way to build exercise into the daily routine while reducing your carbon footprint. But Mike’s experience underscores why many people don’t engage in active transportation–they don’t feel safe on our streets. I want that to change.

This project’s goal is to rebuild the environment of streets in Indy. We will engage community members around the city to design interventions for the highest risk regions to pedestrians/bicyclists. Then we’ll use randomized controlled trials to test what helps protect people with the best efficacy and dollar efficiency.

Intro

In this analysis, we will kick off the first of IndyCrash’s objectives by plotting all crashes involving active mobility (walking or bicycling) on an interactive map of the Indianapolis metropolitan area. Once we have visualized crashes, we can use these maps for reference while building more sophisticated analyses. They’ll help us verify that our results make sense.

Let’s get started by loading the needed R programming libraries.

Part 1: Visualizing by mode of active mobility

Each sub-category of active mobility is plotted on the map below. Hover over the icon on the top right above the legend to toggle each category on and off.

Sidenote: If you are interested in learning how the data was generated, please reference here.

#Load crashes involving active mobility for the Indy metro area
crashes <- read_feather("ariesCrashes.feather") %>%
    filter(county %in% c("Marion", "Boone", "Hamilton", "Madison", "Hancock", "Shelby", "Johnson", "Morgan", "Hendricks") &
             crashActive == TRUE)

#Construct base map
m <- leaflet(crashes, options = leafletOptions(minZoom = 8)) %>%
  #Load map tiles from CartoDB
  addProviderTiles("CartoDB") %>% 
  #Set focal point of the map
  setView(lng = -86.158, lat = 39.768, zoom =9) %>%
  #Set bounds of the map
  setMaxBounds(lng1 = -86.158 + 0.7,
               lat1 = 39.768 + 0.7,
               lng2 = -86.158 - 0.7,
               lat2 = 39.768 - 0.7) %>%
  #Add toggle to full screen
  addFullscreenControl()

#Set color palette for mode of travel
palMode <- colorFactor(palette = c("blue","red","purple"),
                   levels = c("Pedestrian", "Bicyclist","Both"))

#Define map for plotting mode of travel
mMode <- m %>%
  #Add markers
  addCircles(group = ~crashActiveMode,
             lng = ~long,
             lat = ~lat,
             radius = 25,
             stroke = FALSE,
             opacity = 0.3,
             color = ~palMode(crashActiveMode),
             popup = ~paste0("<b>Record Number: ",as.character(INDIVIDUAL_MR_RECORD),"</b>",
                             "<br/>Date: ",date,
                             "<br/>Location Description: ",locationID,
                             "<br/>Speed Limit: ",speedLimit,
                             "<br/>Child Involved: ",childInvolved,
                             "<br/>In a school zone: ",schoolZone,
                             "<br/>Number of people injured: ",numberInjured,
                             "<br/>Number of people killed: ",numberDead)) %>%
  #Add legend
  addLegend(title = "Mode of Active Mobility Involved:",
            values = ~crashActiveMode,
            pal = palMode,
            position = "bottomleft") %>%
  #Add toggle for different groups
  addLayersControl(overlayGroups = c("Bicyclist","Both","Pedestrian"),
                   position = "topright")

mMode

Part 2: Visualizing by year

In order to evaluate the effects of preventative interventions, it is important to see how crash distributions are changing over time. Similar to above, hover over the top-right icon to toggle the plots of each year on and off.

#Set color palette for year
palYear <- colorFactor("Spectral",crashes$year)

#Define map for plotting crashes by year
mYear <- m %>% addCircles(lng = ~long,
                          lat = ~lat,
                          radius = 25,
                          weight = 2,
                          fillOpacity = 0.7,
                          color = ~palYear(year),
                          group = ~as.character(year),
                          popup = ~paste0("<b>Record Number: ",as.character(INDIVIDUAL_MR_RECORD),"</b>",
                                          "<br/>Date: ",date,
                                          "<br/>Location Description: ",locationID,
                                          "<br/>Mode of Active Mobility: ",crashActiveMode,
                                          "<br/>Speed Limit: ",speedLimit,
                                          "<br/>Child Involved: ",childInvolved,
                                          "<br/>In a school zone: ",schoolZone,
                                          "<br/>Number of people injured: ",numberInjured,
                                          "<br/>Number of people killed: ",numberDead))  %>%
  #Add legend
  addLegend(title = "Year",
            values = ~year,
            pal = palYear,
            position = "bottomleft") %>%
  #Add toggle for different groups
  addLayersControl(overlayGroups = c(as.character(2007:2019)),
                   position = "topright")

#Generate map plotting crashes by year
mYear

Although these maps allow us to visualize crash sites with highly granular detail, it’s admittedly difficult to see the big picture. That’s why my next analysis will focus on identifying hot spots around the metro area.